# Create your views here.

from django.shortcuts import render_to_response
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.contrib.auth import logout
from market.authentification import authentificatePlayer, authentificateUser
from django.template import RequestContext
from market.models import UserProfile, BetRoom, Player, WebSiteComment
from market.jsonsForCharts import getComments
from market.cometHelper import getChatRoomPlayerStatus
from market.models import BetRoom, MarketPlacePlayerMarketUpToDateStatus, ChatRoomPlayerUpToDateStatus
from market.exceptionHandler import handleRequestPlayerPOSTWithExceptionWhenNotSuspended
from market.exceptionHandler import handleRequestUserPOSTWithException
from django.utils import simplejson

##################

# FUNCTION CALLED

##################
from market.marketAction import sellAsset0
from market.marketAction import SubmitNewRepartition0
from market.marketAction import SubmitNewStrategyMtMRep0
from market.marketAction import addSelectedStratInTable0
from market.marketAction import removeUninvestedStratFromTable0
from market.marketAction import killAssetInGloryMode0
        



###########################################################################################
# implementation of rules 2 : the player change his strategy submitting a new one
# this is "part 1" where the new strategy is extract from the post request
def SubmitNewRepartition(request):
        return handleRequestPlayerPOSTWithExceptionWhenNotSuspended(  globals()["SubmitNewRepartition0"], request )
               

###########################################################################################
# implementation of rules 2Ter : the player change his strategy via selling a specified number of the specified asset
def sellAsset(request):
        return handleRequestPlayerPOSTWithExceptionWhenNotSuspended( globals()["sellAsset0"], request )


        
###########################################################################################
# return the page with the rules and the explanation
def SubmitNewStrategyMtMRep(request):
        return handleRequestPlayerPOSTWithExceptionWhenNotSuspended( globals()["SubmitNewStrategyMtMRep0"] , request )
        


###########################################################################################
# add the strategy to the invested strategy ansd set the percentage to 0
def addSelectedStratInTable(request):
        return handleRequestPlayerPOSTWithExceptionWhenNotSuspended( globals()["addSelectedStratInTable0"], request )

###########################################################################################
# suppress the asset per strategy when they are useless
def removeUninvestedStratFromTable(request):
        return handleRequestPlayerPOSTWithExceptionWhenNotSuspended( globals()["removeUninvestedStratFromTable0"], request )
        
################################################################################################################
# identification the pay dividend and kill asset at constant MtM
def killAssetInGloryMode(request):
        return handleRequestPlayerPOSTWithExceptionWhenNotSuspended( globals()["killAssetInGloryMode0"], request )


        

